POV-Ray : Newsgroups : povray.newusers : Problem: using difference : Problem: using difference Server Time
4 Nov 2024 21:24:59 EST (-0500)
  Problem: using difference  
From: Peter
Date: 11 Oct 2002 02:12:59
Message: <3da66bea@news.povray.org>
Hi - can someone please help me get this difference right?  I'm just new to 
povray, so there is probably something simple I'm missing.

Aim: to get a curved row of square holes in a ring.
I thought I'd use a torus for the ring, some boxes for the holes and 
difference to punch the holes in the ring.

The script below illustrates what I'm after.  Set the switch swt at the top 
to see different parts;
swt = 0 shows the plain ring
swt = 1 shows the bent row of boxes by themselves
swt = 2 shows a straight row of holes in the ring
swt = 3 shows a bent row of holes in the ring - except it doesn't work.

Can someone please advise me how to get this difference function working?  
(Or advise a better way to do this?)

TIA

Peter

PS the bend.inc file is by Chris Colefax.
http://www.geocities.com/SiliconValley/Lakes/1434/bend.html
-----------------------------
// test piece for bend.inc tool

light_source { <-10,10,-20>  color rgb <1,1,1> }

camera {  location  <0, -2, -5>
  look_at   <0, 0,  0>
  right     x*image_width/image_height  
}

#declare swt = 0;  // swt = 0, 1, 2, 3 

#declare torus1 = torus {  1.273,  0.3 
  rotate<90,0,0>
  scale<1,1,.2>
}

#declare boxes = union {
 box{< 0.0, -1.47, -1> < 0.2, -1.27, 1>}
 box{< 0.2, -1.27, -1> < 0.4, -1.07, 1>}
 box{< 0.4, -1.47, -1> < 0.6, -1.27, 1>}
 box{< 0.6, -1.27, -1> < 0.8, -1.07, 1>}
 box{< 0.8, -1.47, -1> < 1.0, -1.27, 1>}
 box{< 1.0, -1.27, -1> < 1.2, -1.07, 1>}
 box{< 1.2, -1.47, -1> < 1.4, -1.27, 1>}
 box{< 1.4, -1.27, -1> < 1.6, -1.07, 1>}
 box{< 1.6, -1.47, -1> < 1.8, -1.27, 1>}
 box{< 1.8, -1.27, -1> < 2.0, -1.07, 1>}
}

#if (swt = 0) #declare theshape = object { torus1 }

#else

// bend options
#declare object_axis1 = < 0, -1.27, 0>;
#declare object_axis2 = < 2, -1.27, 0>;
#declare bend_angle = 90;
#declare bend_direction = y;
#declare bend_object = object{ boxes }
#declare bent_object = object{
 #include "Bend.inc"
}
#if (swt = 1) #declare theshape = object{ bent_object }

#else 

#if (swt = 2) 
#declare theshape = difference{
 object{ torus1 }
 object{ bend_object }
}

#else
#declare theshape = difference{
 object{ torus1 }
 object{ bent_object }
}
#end
#end
#end

object{ theshape
 pigment{color rgb<.4,.3,.8>}
}
-----------------------------


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.